﻿namespace jQube.Web.UI
{
    using System;
    using System.Collections;
    using System.Collections.Generic;

    public class ScriptReferenceEnumerator : IEnumerator<ScriptReference>
    {
        private ScriptReferenceCollection scriptReferenceCollection;
        private IEnumerator enumerator;

        private ScriptReferenceEnumerator()
        {
        }

        internal ScriptReferenceEnumerator(ScriptReferenceCollection scriptReferenceCollection)
        {
            this.scriptReferenceCollection = scriptReferenceCollection;
            this.enumerator = scriptReferenceCollection.List.GetEnumerator();
        }

        #region Miembros de IEnumerator<ScriptReference>

        ScriptReference IEnumerator<ScriptReference>.Current
        {
            get { return this.enumerator.Current as ScriptReference; }
        }

        #endregion

        #region Miembros de IDisposable

        void IDisposable.Dispose()
        {
            this.enumerator = null;
            this.scriptReferenceCollection = null;
            GC.SuppressFinalize(this);
        }

        #endregion

        #region Miembros de IEnumerator

        object IEnumerator.Current
        {
            get { return this.enumerator.Current; }
        }

        bool IEnumerator.MoveNext()
        {
            return this.enumerator.MoveNext();
        }

        void IEnumerator.Reset()
        {
            this.enumerator.Reset();
        }

        #endregion
    }
}
